package cn.pn.project.service;

import cn.pn.project.mapper.schedule.*;
import cn.pn.project.pojo.schedule.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 排期接口提供：xyx
 */
@RestController
public class SchedulerOrderService {

    @Autowired
    private SeatDao seatDao;

    @Autowired
    private TicketFileDao ticketFileDao;

    @Autowired
    private PlaceDao placeDao;

    @Autowired
    private CommoditysessionDao commoditysessionDao;

    @Autowired
    private SeatcommodityDao seatcommodityDao;

    /**
     * 多条件查询座位信息对象（谢耀翔）
     * @param param
     * @return
     * @throws Exception
     */
    @PostMapping("/getSeatByMap")
    public Seat getSeatByMap(@RequestParam Map<String,Object> param)throws Exception{
        System.out.println("*************************多条件查询座位信息对象（谢耀翔）param:"+param);
        return seatDao.getSeatByMap(param);
    }

    /**
     * 多条件查询票档对象（谢耀翔）
     * @param param
     * @return
     * @throws Exception
     */
    @PostMapping("/getTicketFileByMap")
    public Ticketfile getTicketFileByMap(@RequestParam Map<String,Object> param)throws Exception{
        System.out.println("*************************多条件查询票档对象（谢耀翔）param:"+param);
        return ticketFileDao.getTicketFileByMap(param);
    }

    /**
     * 多条件查询场地集合（谢耀翔）
     * @param param
     * @return
     * @throws SQLException
     */
    @PostMapping("/getPlaceListByMap")
    public List<Place> getPlaceListByMap(@RequestParam Map<String,Object> param) throws SQLException{
        System.out.println("*************************多条件查询场地集合（谢耀翔）param:"+param);
        return placeDao.getPlaceListByMap(param);
    }

    /**
     * 多条件查询场地对象（谢耀翔）
     * @param param
     * @return
     * @throws Exception
     */
    @PostMapping("/getPlaceByMap")
    public Place getPlaceByMap(@RequestParam Map<String,Object> param)throws Exception{
        System.out.println("*************************多条件查询场地对象（谢耀翔）param:"+param);
        return placeDao.getPlaceByMap(param);
    }

    /**
     * 多条件查询场次集合（谢耀翔）
     * @param param
     * @return
     * @throws SQLException
     */
    @PostMapping("/getCommoditysessionListByMap")
    public List<Commoditysession> getCommoditysessionListByMap(@RequestParam Map<String,Object> param) throws SQLException{
        System.out.println("*************************多条件查询场次集合（谢耀翔）param:"+param);
        return commoditysessionDao.getCommoditysessionListByMap(param);
    }

    /**
     * 多条件查询场次对象（谢耀翔）
     * @param param
     * @return
     * @throws Exception
     */
    @PostMapping("/getCommoditysessionByMap")
    public Commoditysession getCommoditysessionByMap(@RequestParam Map<String,Object> param)throws Exception{
        System.out.println("*************************多条件查询场次对象（谢耀翔）param:"+param);
        return commoditysessionDao.getCommoditysessionByMap(param);
    }

    /**
     * 新增商品座位记录（谢耀翔）
     * @param seatcommodity
     * @return
     * @throws Exception
     */
    @PostMapping("/insertSeatcommodity")
    public Integer insertSeatcommodity(Seatcommodity seatcommodity)throws Exception{
        System.out.println("*************************新增商品座位记录（谢耀翔）param:"+seatcommodity.toString());
        return seatcommodityDao.insertSeatcommodity(seatcommodity);
    }

    @PostMapping("/updateTicketRepertory")
    public Integer updateTicketRepertory(@RequestParam(value = "ticketfileid",required = false) Integer ticketfileid,@RequestParam(value = "count",required = false) Integer count){
        return ticketFileDao.updateTicketRepertory(ticketfileid,count);
    }

}
